package com.cby.olive.sample.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * Description:MainPageAdapter
 *
 * @author chenbaoyang
 * @create 2023/6/14 16:33
 */
class MainPageAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {

    private val fragmentList = arrayListOf<Fragment>()

    fun setData(fragments: ArrayList<Fragment>) {
        fragmentList.addAll(fragments)
        notifyDataSetChanged()
    }

    override fun getItemCount() = fragmentList.size

    override fun createFragment(position: Int): Fragment {
        return fragmentList[position]
    }
}